# Maintainer: Ryuta Suzuki <oroppas@gmail.com>

_realname=openpyxl
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
provides=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
conflicts=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
replaces=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
pkgver=3.0.3
pkgrel=1
pkgdesc="A python library to read/write Excel 2007 xlsx/xlsm file (mingw-w64)"
url="https://openpyxl.readthedocs.io/"
arch=('any')
license=('MIT')
depends=("${MINGW_PACKAGE_PREFIX}-python-jdcal"
         "${MINGW_PACKAGE_PREFIX}-python-et-xmlfile"
         "${MINGW_PACKAGE_PREFIX}-python-defusedxml"
         "${MINGW_PACKAGE_PREFIX}-python-pandas"
         "${MINGW_PACKAGE_PREFIX}-python-pillow")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-setuptools"
             "${MINGW_PACKAGE_PREFIX}-python-pip"
             "${MINGW_PACKAGE_PREFIX}-python-pytest")
_pkgtag='ca7b1baf75f2'
source=(openpyxl-${pkgver}.tar.gz::"https://bitbucket.org/openpyxl/openpyxl/get/${pkgver}.tar.gz"
        "LICENSE")
sha256sums=('98e6cbdaa6535ed46fbbf38c10dc447547cd95ea73d33a21035a7c4a21f5e2a2'
            '717016f755510c08d8752a7d2cf0a355624d380b68b88e9d92ea153ea896daaa')

prepare() {
  rm -rf python-build-${CARCH}
  cp -r "openpyxl-openpyxl-${_pkgtag}" "python-build-${CARCH}"
}

build() {
  msg "Python build for ${CARCH}"
  cd "${srcdir}/python-build-${CARCH}"
  ${MINGW_PREFIX}/bin/python setup.py build
}

package() {
  cd "${srcdir}/python-build-${CARCH}"
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python setup.py install --prefix=${MINGW_PREFIX} \
    --root="${pkgdir}" --optimize=1 --skip-build

  install -Dm644 ${srcdir}/LICENSE ${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE
}
